package com.rs.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 车辆状态
 *
 * @author zhouwz
 * @date 2020/6/19 10:46
 */
@AllArgsConstructor
public enum VehicleStatus {
    /**
     * 车辆状态
     */
    IDLE("IDLE", "闲置"),
    CHARGE("CHARGE", "充电"),
    SUSPEND("SUSPEND", "暂停"),
    ABNORMAL("ABNORMAL", "异常"),
    OFF_LINE("OFF_LINE", "离线"),
    DEACTIVATE("DEACTIVATE", "停用"),
    EXECUTION("EXECUTION", "执行"),
    ERROR("ERROR", "无该状态"),
    ;
    @Getter
    private final String code;
    @Getter
    private final String msg;

    public static VehicleStatus getVehicleStatus(String code) {
        for (VehicleStatus item : VehicleStatus.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return ERROR;
    }
}
